home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 21
/
Cream of the Crop 21 (Terry Blount) (October 1996).iso
/
comm
/
msged400.zip
/
src
/
bmg.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-06-20
|
1KB
|
53 lines
/*
* BMG.C
*
* Written by Paul Edwards and released to the public domain.
*
* Emulate Boyer-More-Gosper routines, without actually doing it, because
* Msged doesn't use the proper functionality, for unknown reasons.
*/
#include <string.h>
#include <ctype.h>
#include "bmg.h"
#include "strextra.h"
static char search_string[256];
void bmg_setsearch(char *search)
{
strcpy(search_string, search);
}
char *bmg_search(char *text)
{
return bmg_find(text, search_string);
}
char *bmg_find(char *text, char *search)
{
char *endText, *p;
int lent, lens, searchStart;
lent = strlen(text);
lens = strlen(search);
if (lens > lent)
{
return NULL;
}
searchStart = toupper(*search);
p = text;
endText = p + (lent - lens) + 1;
for (; p != endText; p++)
{
if (toupper(*p) == searchStart)
{
if (strncmpi(p, search, lens) == 0)
{
return p;
}
}
}
return NULL;
}